package com.example.demo.service.Impl;

import com.example.demo.mapper.HelldeviceMapper;
import com.example.demo.pojo.Helldevice;
import com.example.demo.pojo.Lifebook;
import com.example.demo.service.HelldeviceServicce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class HelldeviceServiceImpl implements HelldeviceServicce {
    @Autowired
    private HelldeviceMapper helldeviceMapper;
    //地府设备查询
    public PageInfo HelldeviceQuery(Integer page, Integer limit, Integer floor) {
        //    1.获取总记录数
        PageHelper.startPage(page,limit);
        //    2.执行操作
        List<Helldevice> list = helldeviceMapper.HelldeviceQuery(floor);
        PageInfo<Helldevice> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
    //地府设备添加
    @Override
    public void HelldeviceAdd(Helldevice helldevice) {
        helldevice.setCreate_time(LocalDateTime.now());
        helldevice.setStatus(0);
        helldeviceMapper.HelldeviceAdd(helldevice);
    }
    //地府设备修改
    @Override
    public void HelldeviceUpdate(Helldevice helldevice) {
        helldevice.setCreate_time(LocalDateTime.now());
        helldeviceMapper.HelldeviceUpdate(helldevice);
    }
    //地府设备开启或关闭
    @Override
    public void HelldeviceUpdateStatus(Helldevice helldevice) {
        helldevice.setCreate_time(LocalDateTime.now());
        helldeviceMapper.HelldeviceUpdateStatus(helldevice);
    }
    //地府设备删除
    @Override
    public void HelldeviceDelete(Integer id) {
        helldeviceMapper.HelldeviceDelete(id);
    }
}
